package com.shenfa.dao;

import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ibatis.SqlMapClientTemplate;

import com.shenfa.bean.bill.rule.DimensionInfo;
import com.shenfa.tools.SteelTools;

/**
 * 维度信息表映射dao
 * 
 * @author Administrator
 *
 */
public class DimensionInfoDao {

	@Autowired
	private SqlMapClientTemplate sqlMapClientTemplate;
	
	/**
	 * 查询维度表信息
	 * 
	 * @param dimid
	 * @param skipResults
	 * @param maxResults
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<DimensionInfo> queryGridList(int skipResults, int maxResults){
		return sqlMapClientTemplate.queryForList("dimension_manager.query_dimension",skipResults, maxResults);
	}
	
	/**
	 * 查询维度总条数
	 * 
	 * @return
	 */
	public int dimenPageTotal(){
		return (Integer)sqlMapClientTemplate.queryForObject("dimension_manager.query_dimensionlist");
	}
	
	
	/**
	 * 新增维度表信息
	 * 
	 * @param dimen
	 * @return
	 */
	public boolean addDimension(DimensionInfo dimen){
		sqlMapClientTemplate.insert("dimension_manager.add_dimension", dimen);
		return true;
	}
	
	/**
	 * 修改维度表信息
	 * 
	 * @param dimen
	 * @return
	 */
	public boolean editDimension(DimensionInfo dimen){
		sqlMapClientTemplate.update("dimension_manager.edit_dimension", dimen);
		return true;
	}
	
	/**
	 * 删除维度表信息
	 * 
	 * @param i
	 * @return
	 */
	public boolean deleteDimension(int i){
		sqlMapClientTemplate.delete("dimension_manager.delete_dimension", i);
		return true;
	}

	/**
	 * 验证维度类型编号
	 * @param field_type
	 * @return
	 */
	public int validateField(int field_type) {
		int num = -1;
		num = (Integer)sqlMapClientTemplate.queryForObject("dimension_manager.validate", field_type);
		return num;
	}
}
